package com.apes.scm.masterdata.enumeration.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.scm.masterdata.enumeration.model.BusinessParam;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface BusinessParamRepository extends CustomRepository<BusinessParam, String> {

    List<BusinessParam> findAllByQueryKey(String queryKey);

    @Query(value = "SELECT * FROM MAS_BUSINESS_PARAM WHERE QUERY_KEY = 'accordingToCompanyContract' AND VALUE2 IN :value2 ", nativeQuery = true)
    List<BusinessParam> accordingToCompanyContract( @Param("value2") List value2);

    @Query("select t from BusinessParam t where t.queryKey = :queryKey and t.value3 = :value3 and (t.value = :value or t.value2 = :value )")
    List<BusinessParam> findAllByQueryKeyAndValue(@Param("queryKey")String queryKey, @Param("value")String value, @Param("value3")String value3);
}
